package com.springCloud.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 消息体
 * @author zhu
 * @date 2019/12/31 21:59
 * @version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message<T> {
    private String code;
    private String message;
    private T data;

    public static Message ok() {
        return new Message<>("00", "操作成功", null);
    }

    public static Message ok(String code, String message) {
        return new Message<>(code, message, null);
    }

    public static<T> Message ok(String code, String message, T data) {
        return new Message<>(code, message, data);
    }

    public static Message error() {
        return new Message<>("B0", "操作失败", null);
    }

    public static Message error(String code, String message) {
        return new Message<>(code, message, null);
    }

    public static<T> Message error(String code, String message, T data) {
        return new Message<>(code, message, data);
    }

}
